package com.example.exerciseextract.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.exerciseextract.R;
import com.example.exerciseextract.bean.RvBean;

import java.util.ArrayList;

/**
 * Created by 阿炜啊 on 2020/7/12.
 */

public class RvAdapter extends RecyclerView.Adapter<RvAdapter.ViewHolder> {
    private Context context;
    private ArrayList<RvBean.DataBean.DatasBean> list;

    public RvAdapter(Context context, ArrayList<RvBean.DataBean.DatasBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.rv, null);

        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ViewHolder viewHolder = holder;
        viewHolder.mTvRv.setText(list.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView mTvRv;
        public ViewHolder(View itemView) {
            super(itemView);
            this.mTvRv = (TextView) itemView.findViewById(R.id.tv_rv);
        }
    }


}
